package com.yhb.myshop.web.admin.web.controller;

import com.yhb.myshop.commons.entity.BaseResult;
import com.yhb.myshop.commons.entity.PageQuery;
import com.yhb.myshop.commons.entity.PageResult;
import com.yhb.myshop.commons.entity.dto.TbUserQuery;
import com.yhb.myshop.domain.TbUser;
import com.yhb.myshop.web.admin.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/user")
public class UserController extends BaseController<TbUser,UserService> {

    @ResponseBody
    @RequestMapping("/page")
    public PageResult<TbUser> page(PageQuery<TbUserQuery> pageQuery, TbUserQuery query) {
        pageQuery.setQuery(query);
        PageResult<TbUser> tbUsers = service.getByPage(pageQuery);
        return tbUsers;
    }



    @Override
    protected TbUser initFormEntity() {
        return new TbUser();
    }


}
